Binary code to Gray code conversion with practical explanation